<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改短链接')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-url-edit" th:object="${shortUrl}">
            <input name="shortCode" th:field="*{shortCode}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">主要域名：</label>
                <div class="col-sm-8">
                	<div th:text="${shortUrl.mainDomain+'/'+shortUrl.shortCode}"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">如主域名失效，可用其他域名替换：</label>
                <div class="col-sm-8">
                	<div th:if="${#lists.isEmpty(otherDomains)}">无</div>
                	<div th:if="${!#lists.isEmpty(otherDomains)}" th:each="domain : ${otherDomains}" th:value="${domain.domain+'/'+shortUrl.shortCode}" th:utext="${domain.domain+'/'+shortUrl.shortCode+'<br/>'}"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">目标地址：</label>
                <div class="col-sm-8">
                    <input name="targetUrl" th:field="*{targetUrl}" class="form-control" type="text" required>
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">打开方式：</label>
                <div class="col-sm-8">
                    <select name="openWay" th:field="*{openWay}" class="form-control" required>
                    	<option value="FORWARD">直连（地址变为目标地址）</option>
                    	<option value="FRAME">框架（地址仍是短链）</option>
                    </select>
                </div>
            </div>
            
            <div class="form-group">
            	<label th:if="${expireDay!=-1}"  class="col-sm-3 control-label"></label>
            	<label th:if="${expireDay!=-1}"  class="col-sm-8" th:text="${shortUrl.expirationTime+'晚失效'}"></label><br/>
            	<label class="col-sm-3 control-label">多少天后失效(-1表示永久)：</label>
		        <div class="col-sm-8">
		            <div class="input-group date">
                        <input type="number" min="-1" class="form-control" name="expirationTime" id="expirationTime" placeholder="天" th:value="${expireDay}" th:disabled="${!isAdmin}">
                    </div>
		        </div>
		    </div>
		    
		    
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "short/url";
        $("#form-url-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-url-edit').serialize());
            }
        }
    </script>
</body>
</html>